Ext.define('TS.view.base.CustomerList' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.custlist',
    title : '客户资料',
    columnLines: true,
    bodyPadding:0,
    frame : true,//面板渲染
    closable: true,
    store:'base.CustomerStore',
    /* fields: ['customerId', 'parentId','customerCode','customerName','custType',
    'contactMan','telephone','mobilephone','qqNumber','email',
    'address','deliveryAdd','deptId','empId','creditAmount',
    'creditDay','acctLocked','acctExpired','acctEnabled','sfdaCode','remark']
	*/
    columns:[
            {header: '客户编号', dataIndex: 'customerCode',width:80},
            {header: '客户名称', dataIndex: 'customerName',width:200},
            {header: '联系人', dataIndex: 'contactMan', width:50},
            {header: '联系电话', dataIndex: 'telephone',width:100},
            {header: '手机号码', dataIndex: 'mobilephone',width:80},
            {header: 'QQ号', dataIndex: 'qqNumber', width:80},
            {header: '邮箱地址', dataIndex: 'email',width:100},
            {header: '地址', dataIndex: 'address',width:200},
            {header: '收货地址', dataIndex: 'deliveryAdd',width:200},
            {header: '信用金额', dataIndex: 'creditAmount',width:80},
            {header: '信用天数', dataIndex: 'creditDay',width:80},
            {header: '许可证', dataIndex: 'sfdaCode',width:80},
            {header: '备注', dataIndex: 'remark',width:100},
            {
            	header: '帐户锁定', 
            	dataIndex: 'acctLocked',
            	width:50,
            	xtype : "booleancolumn",
				width:50,
				trueText:'是',
				falseText:'否'
            },
            {
	            header: '帐户过期', 
	            dataIndex: 'acctExpired',
	            width:50,
	            xtype : "booleancolumn",
				trueText:'是',
				falseText:'否'
            },
            {header: '负责员工', dataIndex: 'empId',width:50,
            	renderer:function(value,metaData,record){
					return record.raw.emp.empName;
				}
            },
            {header: '负责部门', dataIndex: 'deptId',width:50,
            	renderer:function(value,metaData,record){
					return record.raw.dept.deptName;
				}
            }
    ],
    tbar :[
				{xtype:'button',action:'add',text:'添加',iconCls:'bill-add-button'},
				{xtype:'button',action:'upd',text:'修改',iconCls:'bill-edit-button'},
				{xtype:'button',action:'del',text:'删除',iconCls:'bill-delete-button'},
				{xtype:'button',action:'ref',text:'刷新',iconCls:'bill-ref-button'},
				{
					xtype: 'triggerfield',
					labelWidth :50,
					fieldLabel:'查询:',
					width:250,
					emptyText:'请输入客户编码或名称',
					trigger1Cls:Ext.baseCSSPrefix + "form-search-trigger",
					onTriggerClick:function(e){
						e.keyCode=e.ENTER;//设置为Enter事件
						this.fireEvent('specialkey',this,e);//点客户查询图标执行搜索
					}
				},
				{xtype:'button',action:'recycle',text:'回收站',iconCls:'bill-recycle-button'},
				{xtype:'button',action:'restore',text:'还原',iconCls:'bill-restore-button'},
				{xtype:'button',action:'exportxls',text:'导出',iconCls:'bill-export-button'}
	],
	dockedItems :[{
				xtype:'pagingtoolbar',
				store:'base.CustomerStore',
				dock:'bottom',
				displayInfo:true
				/*,refreshInfo:function(count){
					var me = this,
					displayItem = me.child('#displayItem'),
					store = me.store,
					msg,toRecord,pages;
					if (displayItem) {
						if (count === 0) {
							msg = me.emptyMsg;
							pages=0;
						} else {
							pages=Math.ceil(count / store.pageSize)
							if(count<store.pageSize)
								toRecord=count;
							else
								toRecord=store.pageSize;
							msg = Ext.String.format(
								me.displayMsg,
								1,
								toRecord,
								count
							);
						}
						me.pageData={currentPage:1,fromRecord:1,pageCount:pages,toRecord:toRecord,total:count};
						me.updateInfo();
						displayItem.setText(msg);
					}
			    }*/
	}],
	selType:'checkboxmodel',//设定选择模式
	multiSelect:true,//运行多选
	initComponent:function(){
		this.callParent(arguments);
	},
	listeners: {
		render:{
			fn:function(){
				this.store.on("beforeload",function(store){
				        Ext.apply(store.proxy.extraParams, {val:"all"});
				});
				this.store.loadPage(1,{
					params:{val:"all"},
		    		callback:function(records, operation, success){
		    			console.log(success);
		    		},
			   		scope: this
			   	});
			}
		}
	}
});
